<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Numerical Definitions</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="prev" href="glib-Byte-Order-Macros.html" title="Byte Order Macros">
<link rel="next" href="glib-Miscellaneous-Macros.html" title="Miscellaneous Macros">
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="glib.html" title="GLib Overview">
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
<link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
<link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
<link rel="chapter" href="tools.html" title="GLib Tools">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
<link rel="index" href="ix10.html" title="Index of new symbols in 2.16">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Byte-Order-Macros.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-fundamentals.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-Miscellaneous-Macros.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2899930" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id2900046" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="glib-Numerical-Definitions"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id2899930"></a><span class="refentrytitle">Numerical Definitions</span>
</h2>
<p>Numerical Definitions &#8212; mathematical constants, and floating point decomposition</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">

#include &lt;glib.h&gt;


#define             <a class="link" href="glib-Numerical-Definitions.html#G-IEEE754-FLOAT-BIAS:CAPS">G_IEEE754_FLOAT_BIAS</a>
#define             <a class="link" href="glib-Numerical-Definitions.html#G-IEEE754-DOUBLE-BIAS:CAPS">G_IEEE754_DOUBLE_BIAS</a>
union               <a class="link" href="glib-Numerical-Definitions.html#GFloatIEEE754">GFloatIEEE754</a>;
union               <a class="link" href="glib-Numerical-Definitions.html#GDoubleIEEE754">GDoubleIEEE754</a>;


#define             <a class="link" href="glib-Numerical-Definitions.html#G-E:CAPS">G_E</a>
#define             <a class="link" href="glib-Numerical-Definitions.html#G-LN2:CAPS">G_LN2</a>
#define             <a class="link" href="glib-Numerical-Definitions.html#G-LN10:CAPS">G_LN10</a>
#define             <a class="link" href="glib-Numerical-Definitions.html#G-PI:CAPS">G_PI</a>
#define             <a class="link" href="glib-Numerical-Definitions.html#G-PI-2:CAPS">G_PI_2</a>
#define             <a class="link" href="glib-Numerical-Definitions.html#G-PI-4:CAPS">G_PI_4</a>
#define             <a class="link" href="glib-Numerical-Definitions.html#G-SQRT2:CAPS">G_SQRT2</a>
#define             <a class="link" href="glib-Numerical-Definitions.html#G-LOG-2-BASE-10:CAPS">G_LOG_2_BASE_10</a>
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2900046"></a><h2>Description</h2>
<p>
GLib offers mathematical constants such as <a class="link" href="glib-Numerical-Definitions.html#G-PI:CAPS"><span class="type">G_PI</span></a> for the value of pi;
many platforms have these in the C library, but some don't, the GLib
versions always exist.
</p>
<p>
The <a class="link" href="glib-Numerical-Definitions.html#GFloatIEEE754"><span class="type">GFloatIEEE754</span></a> and <a class="link" href="glib-Numerical-Definitions.html#GDoubleIEEE754"><span class="type">GDoubleIEEE754</span></a> unions are used to access the
	sign, mantissa and exponent of IEEE floats and doubles. These
	unions are defined as appropriate for a given platform. 
 IEEE floats and doubles are supported (used for
	storage) by at least Intel, PPC and Sparc, for reference: <a class="ulink" href="http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html" target="_top">http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html</a>
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2900104"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id2900114"></a><h3>
<a name="G-IEEE754-FLOAT-BIAS:CAPS"></a>G_IEEE754_FLOAT_BIAS</h3>
<a class="indexterm" name="id2900127"></a><pre class="programlisting">#define G_IEEE754_FLOAT_BIAS	(127)
</pre>
<p>
See <a class="ulink" href="http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html" target="_top">http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html</a>
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900151"></a><h3>
<a name="G-IEEE754-DOUBLE-BIAS:CAPS"></a>G_IEEE754_DOUBLE_BIAS</h3>
<a class="indexterm" name="id2900164"></a><pre class="programlisting">#define G_IEEE754_DOUBLE_BIAS	(1023)
</pre>
<p>
See <a class="ulink" href="http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html" target="_top">http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html</a>
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900188"></a><h3>
<a name="GFloatIEEE754"></a>union GFloatIEEE754</h3>
<a class="indexterm" name="id2900200"></a><pre class="programlisting">union GFloatIEEE754
{
  gfloat v_float;
  struct {
    guint mantissa : 23;
    guint biased_exponent : 8;
    guint sign : 1;
  } mpn;
};
</pre>
<p>
The <a class="link" href="glib-Numerical-Definitions.html#GFloatIEEE754"><span class="type">GFloatIEEE754</span></a> and <a class="link" href="glib-Numerical-Definitions.html#GDoubleIEEE754"><span class="type">GDoubleIEEE754</span></a> unions are used to access the
	sign, mantissa and exponent of IEEE floats and doubles. These
	unions are defined as appropriate for a given platform. 
 IEEE floats and doubles are supported (used for
	storage) by at least Intel, PPC and Sparc, for reference: 
<a class="ulink" href="http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html" target="_top">http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html</a>
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900247"></a><h3>
<a name="GDoubleIEEE754"></a>union GDoubleIEEE754</h3>
<a class="indexterm" name="id2900260"></a><pre class="programlisting">union GDoubleIEEE754
{
  gdouble v_double;
  struct {
    guint mantissa_low : 32;
    guint mantissa_high : 20;
    guint biased_exponent : 11;
    guint sign : 1;
  } mpn;
};
</pre>
<p>
The <a class="link" href="glib-Numerical-Definitions.html#GFloatIEEE754"><span class="type">GFloatIEEE754</span></a> and <a class="link" href="glib-Numerical-Definitions.html#GDoubleIEEE754"><span class="type">GDoubleIEEE754</span></a> unions are used to access the
	sign, mantissa and exponent of IEEE floats and doubles. These
	unions are defined as appropriate for a given platform. 
 IEEE floats and doubles are supported (used for
	storage) by at least Intel, PPC and Sparc, for reference: 
<a class="ulink" href="http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html" target="_top">http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html</a>
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900307"></a><h3>
<a name="G-E:CAPS"></a>G_E</h3>
<a class="indexterm" name="id2900319"></a><pre class="programlisting">#define G_E     2.7182818284590452353602874713526624977572470937000
</pre>
<p>
The base of natural logarithms.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900335"></a><h3>
<a name="G-LN2:CAPS"></a>G_LN2</h3>
<a class="indexterm" name="id2900347"></a><pre class="programlisting">#define G_LN2   0.69314718055994530941723212145817656807550013436026
</pre>
<p>
The natural logarithm of 2.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900363"></a><h3>
<a name="G-LN10:CAPS"></a>G_LN10</h3>
<a class="indexterm" name="id2900376"></a><pre class="programlisting">#define G_LN10  2.3025850929940456840179914546843642076011014886288
</pre>
<p>
The natural logarithm of 10.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900392"></a><h3>
<a name="G-PI:CAPS"></a>G_PI</h3>
<a class="indexterm" name="id2900405"></a><pre class="programlisting">#define G_PI    3.1415926535897932384626433832795028841971693993751
</pre>
<p>
The value of pi (ratio of circle's circumference to its diameter).
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900422"></a><h3>
<a name="G-PI-2:CAPS"></a>G_PI_2</h3>
<a class="indexterm" name="id2900435"></a><pre class="programlisting">#define G_PI_2  1.5707963267948966192313216916397514420985846996876
</pre>
<p>
Pi divided by 2.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900451"></a><h3>
<a name="G-PI-4:CAPS"></a>G_PI_4</h3>
<a class="indexterm" name="id2900463"></a><pre class="programlisting">#define G_PI_4  0.78539816339744830961566084581987572104929234984378
</pre>
<p>
Pi divided by 4.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900479"></a><h3>
<a name="G-SQRT2:CAPS"></a>G_SQRT2</h3>
<a class="indexterm" name="id2900492"></a><pre class="programlisting">#define G_SQRT2 1.4142135623730950488016887242096980785696718753769
</pre>
<p>
The square root of two.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2900508"></a><h3>
<a name="G-LOG-2-BASE-10:CAPS"></a>G_LOG_2_BASE_10</h3>
<a class="indexterm" name="id2900522"></a><pre class="programlisting">#define G_LOG_2_BASE_10		(0.30102999566398119521)
</pre>
<p>
Used for fooling around with float formats, see 
<a class="ulink" href="http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html" target="_top">http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html</a>
</p>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id2900547"></a><h2>See Also</h2>
<p>
<a class="ulink" href="http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html" target="_top">http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/ncg_math.doc.html</a>
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2900565"></a><div class="refsect2" lang="en"><a name="id2900566"></a></div>
<hr>
<div class="refsect2" lang="en"><a name="id2900568"></a></div>
</div>
</div>
</body>
</html>
